#ifndef NUMERICUPDOWN_H_
#define NUMERICUPDOWN_H_

#include <D3D9.h>
#include <D3dx9core.h>
#include "Utility.h"

const char texture_pressed_string[] = "arrow_up_pressed.tga";
const char texture_string[] = "arrow_up.tga";

namespace Audio
{
	class AudioPlayer;
}

class NumericUpDown
{
private:
	static const int textureSize = 64;
	int x;
	int y;
	int width;
	int height;
	int min;
	int max;
	int value;
	bool upPressed, downPressed;
	float upScaleX, upScaleY, downScaleX, downScaleY;
	IDirect3DDevice9 * device;
	IDirect3DTexture9 * texture;
	IDirect3DTexture9 * texturePressed;
	ID3DXSprite * sprite;

	Audio::AudioPlayer* _audioPlayer;

	RECT upArrowCoords, downArrowCoords;

	void Init();
	void CalculateArrowCoords();

public:
	NumericUpDown(IDirect3DDevice9 * dev, int x, int y, int width, int height, int min, int max);
	~NumericUpDown();

	void SetDevice(IDirect3DDevice9 * dev);

	bool SetValue(int val);
	int GetValue();

	bool IncreaseValue(int amount);
	bool DecreaseValue(int amount);

	void Render();

	bool MouseButtonDown(int _x, int _y, MouseButtons button);
	bool MouseButtonUp(int _x, int _y, MouseButtons button);

	void SetAudioPlayer(Audio::AudioPlayer* audioPlayer) { _audioPlayer = audioPlayer; }
};

#endif